import React from 'react'
import Layouts from '@/layouts'
import { Routes, Route, Navigate, useSearchParams } from 'react-router-dom'

import Login from '@/views/login'
import { useSelector } from 'react-redux'
export default function App() {
  const { loginState } = useSelector(state => state.adminSlice)
  const [searchParams] = useSearchParams();
  const url = searchParams.get('r')??'/'  
  return (
    <Routes>
      <Route path='/login' element={loginState ? <Navigate to={url} /> : <Login />} />
      <Route path='/*' element={loginState ? <Layouts /> : <Navigate to={'/login'} />} />
    </Routes>
  )
}
